/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vps;

import java.awt.Robot;
import java.awt.event.InputEvent;
import java.util.Properties;

/**
 *
 * @author Hue
 */
public class Click implements Task {
    private Properties params;

    @Override
    public void setProperties(Properties params) {
        this.params = params;
    }

    @Override
    public void run() {
        try {
            Robot robot = new Robot();
            robot.mouseMove(getProperty(params, "x"), getProperty(params, "y"));
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            
            Thread.sleep(3000);
            
            new Screenshot().run();
        }
        catch(Exception ex) {
            ex.printStackTrace();
        }
    }
    
    private int getProperty(Properties config, String key) {
        String value = config.getProperty(key);

        return Integer.parseInt(value);
    }
}
